#ifndef UPLOADMESSAGEINTERFACE_H
#define UPLOADMESSAGEINTERFACE_H

#include <QObject>
#include <QtDBus/QtDBus>
#include <QtDBus/QDBusVariant>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusError>

class KUploadMessage : public QObject
{
    Q_OBJECT
public:
    explicit KUploadMessage(int ppid, QObject *parent = nullptr);
    void initUploadInterface(QString packageName, QString messageType, QString packageInfoIdFolderPath);
    int UploadMessage(const QString &uploadedMessage);
protected:
    QByteArray encrypt(const QByteArray &hasedValue, const QByteArray &keyBase64);
    void evpError(void);
    void checkDir();
    int getProgramPid(const QString &programName);
private:
    static constexpr const char *s_serverName = "com.kylin.daq";
    static constexpr const char *s_objectPath = "/com/kylin/daq";
    static constexpr const char *s_interfaceName = "com.kylin.daq.interface";
    static constexpr const char *s_packageName = "packageName";
    static constexpr const char *s_messageType = "messageType";
    static constexpr const char *s_tid = "tid";
    static constexpr const char *s_uploadMessageMethod = "UploadMessage";
    static constexpr const char *s_uploadMessageConf = "uploadMessage";
    static constexpr const char *publicKey =
        "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FR\
        OEFNSUlCQ2dLQ0FRRUFzdW1NTFJEdlFNb0tEQkRJODRqSgpqc1A0Mk55V0pWVEZob2Jra3ZiT05j\
        dExYTXVzRmo2TzJUblZYU3Z6VlVLSjRqZkpwT2l2WEphOVB5Z2wzYTRnClBzSU40enNCMEdOY0tr\
        R3VsS2RrV2x6S3lWQ2xlTzhiQnN6SjkwbTc3cWF6YWg3a1A0TUl0WTVFczBpSkpiR0oKN1MxcERj\
        MlJkNnVFQWJLaXJyRTFlNzlFTEd4am5VN2V5NWkyRDE2WWJoZEQwZ2lNa2RHR3piQXBKTWZWRVJR\
        TQo1NXorMFVqdS8zSFJhNFY3b3p2TGRPRE5HUURaeWNJU0l3VHBLbFR3RjBxazdCNjVhTUlJenQ1\
        dnhOK1lxYU1GClppZFRLNzcxNjdqNEExZ3F3MG45bjlybWVXUGRWZ3dudnRtVXp4Q1krNk05SXpK\
        TDI3eWpRUTV1WGQ3RVdMT3IKbndJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";

    QString g_packageName;
    QString g_messageType;
    QString g_packageInfoId;
    QString g_packageInfoIdFolderPath;
    QDBusInterface *g_dbusInterface = nullptr;
    bool g_flag = false;
};

#endif // UPLOADMESSAGE_H
